package com.intellij.ide.license.impl;

import com.intellij.ide.license.LicenseFactory;
import com.intellij.licensecommon.data.LicenseData;

import java.util.Date;

public class EvaluationLicenseSource extends AbstractLicenseSource {
    private long c;
    public static final long MS_OF_HOUR = 60 * 60 * 1000L;
    public static final long MS_OF_DAY = 24 * MS_OF_HOUR;

    public EvaluationLicenseSource(LicenseFactory licenseFactory, long paramLong) {
        super(licenseFactory);
        this.c = paramLong;
    }

    public void a() throws com.intellij.ide.license.LicenseException {
        c();
        if (getLicenseData() == null) {
            setLicenseData(this.licenseFactory.createEvaluationLicense());
        }
    }

    public void c() {
        LicenseData license = this.licenseFactory.read();
        setLicenseData(license);
        if (license != null) {
            long l = a(license.getExpirationDate(), new Date());
            if (l > this.c) {
                setLicenseData(null);
            }
        }
    }

    public long g() {
        return this.c;
    }

    public boolean e() {
        return false;
    }

    public static int a(Date paramDate1, Date paramDate2) {
        if (paramDate1 == null) {
            return -1;
        }
        return Math.max(0, (int) ((paramDate1.getTime() - paramDate2.getTime() + MS_OF_HOUR) / MS_OF_DAY));
    }
}
